﻿using System;

namespace Pibby.Core
{
	public enum DownloadActionRequired
	{
		None = 0,
		AuthenticationRequired
	}

	public class DownloadCompleteEventArgs : System.EventArgs
	{
		private const string AUTHENTICATION_REQUIRED_ERROR = "407";

		public DownloadCompleteEventArgs()
			: this(null)
		{
		}

		public DownloadCompleteEventArgs(Exception ex)
		{
			this.Error = ex;
			this.ActionRequired = DownloadActionRequired.None;

			if (ex != null && ex.Message.Contains(AUTHENTICATION_REQUIRED_ERROR))
			{
				this.ActionRequired = DownloadActionRequired.AuthenticationRequired;
			}
		}

		public Exception Error
		{
			get;
			private set;
		}

		public DownloadActionRequired ActionRequired
		{
			get;
			private set;
		}
	}
}
